//
//  WKContenCellViedeoView.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/5.
//  Copyright © 2018年 何文虎. All rights reserved.
//

#import "WKContenCellViedeoView.h"

@interface WKContenCellViedeoView ()
@property(nonatomic,strong)UIImageView *coverImgview;
@property(nonatomic,strong)UIImageView *payImgview;
@property(nonatomic,strong)UILabel *pageViewLb;
@property(nonatomic,strong)UILabel *timeLb;
@end

@implementation WKContenCellViedeoView


- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    self.coverImgview.userInteractionEnabled = YES;
    
    [self addSubview:self.coverImgview];
    
    [self.coverImgview wh_addSubviews:@[self.payImgview,self.pageViewLb,self.timeLb]];
    
   
    
    [self.coverImgview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.width.mas_equalTo(0);
        make.height.mas_equalTo(self.frame.size.height);
    }];
    
    [self.pageViewLb mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 12));
        make.left.mas_equalTo(13);
        make.bottom.mas_equalTo(-13);
    }];
    
    [self.timeLb mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 12));
        make.right.mas_equalTo(-13);
        make.bottom.mas_equalTo(-13);
    }];
    
    [self.payImgview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(36, 36));
        make.center.mas_equalTo(self.coverImgview.center);
    }];

    
    self.payImgview.backgroundColor = [UIColor greenColor];
    self.timeLb.text = @"25:12";
    self.pageViewLb.text = @"浏览量 12w";
    
    self.coverImgview.contentMode = UIViewContentModeScaleAspectFill;
    self.coverImgview.layer.masksToBounds = YES;
    self.coverImgview.layer.cornerRadius = 5;
    
    [self.coverImgview sd_setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1551429363222&di=2107fc162c093466e4de085567f13899&imgtype=0&src=http%3A%2F%2Fi10.hoopchina.com.cn%2Fhupuapp%2Fbbs%2F416%2F18589416%2Fthread_18589416_20181018105247_s_191222_w_903_h_1001_78520.jpg%3Fx-oss-process%3Dimage%2Fresize%2Cw_800%2Fformat%2Cjpg"] placeholderImage:nil];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.coverImgview addGestureRecognizer:tap];
    

}

- (void)tapAction:(UITapGestureRecognizer*)tap{
    NSLog(@"打开视频");
    if (self.playVideoBlock) {
        self.playVideoBlock();
    }
}

- (UIImageView*)coverImgview{
    if (!_coverImgview) {
        _coverImgview = [[UIImageView alloc]init];
    }
    return _coverImgview;
}

- (UIImageView*)payImgview{
    if (!_payImgview) {
        _payImgview = [[UIImageView alloc]init];
    }
    return _payImgview;
}

- (UILabel*)pageViewLb{
    if (!_pageViewLb) {
        _pageViewLb = [[UILabel alloc]init];
        _pageViewLb.textColor = [UIColor whiteColor];
        _pageViewLb.font = PFSC_RegularFont(11);

    }
    return _pageViewLb;
}

- (UILabel*)timeLb{
    if (!_timeLb) {
        _timeLb = [[UILabel alloc]init];
        _timeLb.textColor = [UIColor whiteColor];
        _timeLb.font = PFSC_RegularFont(11);
        _timeLb.textAlignment = NSTextAlignmentRight;
    }
    return _timeLb;
}

@end
